bitkeeper revision 1.1159.238.2 (4200caf6iFnj85XmiFNAz7VursMGUw)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Wed, 2 Feb 2005 12:43:34 +0000 (12:43 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Wed, 2 Feb 2005 12:43:34 +0000 (12:43 +0000)
Slab caches for things allocated only on initialization seems to be
overkill.  This patch replaces them with the previous typesafe
allocator.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: ian.pratt@cl.cam.ac.uk
xen/arch/x86/domain.c
xen/arch/x86/setup.c
xen/common/sched_atropos.c
xen/common/sched_bvt.c
xen/common/sched_rrobin.c

index 6270c09985aaad90bb6bbf96b691e06c18c2e772..be9fd82f0070cdfb150de0fd32e024f89ec190a3 100644 (file)
@@ -223,42 +223,24 @@ void dump_pageframe_info(struct domain *d)
            page->u.inuse.type_info);
 }
 
-xmem_cache_t *domain_struct_cachep;
-xmem_cache_t *exec_domain_struct_cachep;
-
-void __init domain_startofday(void)
-{
-    domain_struct_cachep = xmem_cache_create(
-        "domain_cache", sizeof(struct domain),
-        0, SLAB_HWCACHE_ALIGN, NULL, NULL);
-    if ( domain_struct_cachep == NULL )
-        panic("No slab cache for domain structs.");
-
-    exec_domain_struct_cachep = xmem_cache_create(
-        "exec_dom_cache", sizeof(struct exec_domain),
-        0, SLAB_HWCACHE_ALIGN, NULL, NULL);
-    if ( exec_domain_struct_cachep == NULL )
-        BUG();
-}
-
 struct domain *arch_alloc_domain_struct(void)
 {
-    return xmem_cache_alloc(domain_struct_cachep);
+    return xmalloc(struct domain);
 }
 
 void arch_free_domain_struct(struct domain *d)
 {
-    xmem_cache_free(domain_struct_cachep, d);
+    xfree(d);
 }
 
 struct exec_domain *arch_alloc_exec_domain_struct(void)
 {
-    return xmem_cache_alloc(exec_domain_struct_cachep);
+    return xmalloc(struct exec_domain);
 }
 
 void arch_free_exec_domain_struct(struct exec_domain *ed)
 {
-    xmem_cache_free(exec_domain_struct_cachep, ed);
+    xfree(ed);
 }
 
 void free_perdomain_pt(struct domain *d)
index 5bf8149168d5a688f321e6331874826747724e9c..f38fc62ff417238bc659bd95d128531a006435e0 100644 (file)
@@ -602,8 +602,6 @@ void __init __start_xen(multiboot_info_t *mbi)
     xmem_cache_init();
     xmem_cache_sizes_init(max_page);
 
-    domain_startofday();
-
     start_of_day();
 
     grant_table_init();
index 32c0090fbb9e753fbbefee4f958fbb0c6c674dd9..ab84efa3ce8d40929c36578fd8f22c5f7d2ce4e9 100644 (file)
@@ -69,8 +69,6 @@ struct at_cpu_info
 
 static void at_dump_cpu_state(int cpu);
 
-static xmem_cache_t *dom_info_cache;
-
 static inline void __add_to_runqueue_head(struct domain *d)
 {
     list_add(RUNLIST(d), RUNQ(d->processor));
@@ -558,10 +556,6 @@ static int at_init_scheduler()
         INIT_LIST_HEAD(RUNQ(i));
     }
 
-    dom_info_cache = xmem_cache_create("Atropos dom info",
-                                       sizeof(struct at_dom_info),
-                                       0, 0, NULL, NULL);
-
     return 0;
 }
 
@@ -649,7 +643,7 @@ static int at_adjdom(struct domain *p, struct sched_adjdom_cmd *cmd)
 /* free memory associated with a task */
 static void at_free_task(struct domain *p)
 {
-    xmem_cache_free( dom_info_cache, DOM_INFO(p) );
+    xfree( DOM_INFO(p) );
 }
 
 
index 59b70ecfc6b511e91d7cc85b4376acd14df69602..12c930ac0d29560ac3224ae185d64cd43365afb5 100644 (file)
@@ -71,8 +71,6 @@ struct bvt_cpu_info
 #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
 static s32 ctx_allow = (s32)MILLISECS(5);     /* context switch allowance */
 
-static xmem_cache_t *dom_info_cache;
-
 static inline void __add_to_runqueue_head(struct exec_domain *d)
 {
     list_add(RUNLIST(d), RUNQUEUE(d->processor));
@@ -173,7 +171,7 @@ int bvt_alloc_task(struct exec_domain *ed)
 {
     struct domain *d = ed->domain;
     if ( (d->sched_priv == NULL) ) {
-        if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL )
+        if ( (d->sched_priv = new(struct bvt_dom_info)) == NULL )
             return -1;
         memset(d->sched_priv, 0, sizeof(struct bvt_dom_info));
     }
@@ -295,7 +293,7 @@ static void bvt_sleep(struct exec_domain *d)
 void bvt_free_task(struct domain *d)
 {
     ASSERT(d->sched_priv != NULL);
-    xmem_cache_free(dom_info_cache, d->sched_priv);
+    xfree(d->sched_priv);
 }
 
 /* Control the scheduler. */
@@ -570,14 +568,6 @@ int bvt_init_scheduler()
         CPU_SVT(i) = 0; /* XXX do I really need to do this? */
     }
 
-    dom_info_cache = xmem_cache_create(
-        "BVT dom info", sizeof(struct bvt_dom_info), 0, 0, NULL, NULL);
-    if ( dom_info_cache == NULL )
-    {
-        printk("BVT: Failed to allocate domain info SLAB cache");
-        return -1;
-    }
-
     return 0;
 }
 
index 2164ce22b411fb8d6fcfb767458bdbbd71641b8f..73d03bc787951dd13a52ddbbc9239490a43ad649 100644 (file)
@@ -27,8 +27,6 @@ struct rrobin_dom_info
 #define RUNLIST(d)      ((struct list_head *)&(RR_INFO(d)->run_list))
 #define RUNQUEUE(cpu)   RUNLIST(schedule_data[cpu].idle)
 
-static xmem_cache_t *dom_info_cache;
-
 static inline void __add_to_runqueue_head(struct domain *d)
 {
     list_add(RUNLIST(d), RUNQUEUE(d->processor));
@@ -59,21 +57,12 @@ static int rr_init_scheduler()
     for ( i = 0; i < NR_CPUS; i++ )
         INIT_LIST_HEAD(RUNQUEUE(i));
    
-    dom_info_cache = xmem_cache_create(
-        "RR dom info", sizeof(struct rrobin_dom_info), 0, 0, 0, NULL);
-    if ( dom_info_cache == NULL )
-    {
-        printk("Could not allocate SLAB cache.\n");
-        return -1;
-    }
-
     return 0;                                                                
 }
-
 /* Allocates memory for per domain private scheduling data*/
 static int rr_alloc_task(struct domain *d)
 {
-    if ( (d->sched_priv = xmem_cache_alloc(dom_info_cache)) == NULL )
+    if ( (d->sched_priv = new(struct rrobin_dom_info) == NULL )
         return -1;
     memset(d->sched_priv, 0, sizeof(struct rrobin_dom_info));
     return 0;
@@ -91,7 +80,7 @@ static void rr_add_task(struct domain *d)
 static void rr_free_task(struct domain *d)
 {
     ASSERT(d->sched_priv != NULL);
-    xmem_cache_free(dom_info_cache, d->sched_priv);
+    xfree(d->sched_priv);
 }
 
 /* Initialises idle task */